Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implements RIP-7728 #2

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open

Implements RIP-7728 #2

wants to merge 28 commits into from

Conversation

mralj
Copy link
Collaborator

@mralj mralj commented Sep 25, 2024

This is the first PR (indicated by P1 as in Part 1) needed to implement RIP-7728.

Purpose of the PR

I've decided to split this implementation into multiple parts (there will probably be two parts)

  1. P1 (this PR) "concentrates" on general code structure and skeleton for implementing the rollup precompiles
  2. P2 (next PR) will implement L1SLOAD precompile (actual implementation is easy)

Notes about "code skeleton" for rollup-precompiles

My current view of the project (rollup-geth) is that implementing specific RIPs/EIPs shouldn't be that hard, what I think will be hard is answering (or better said, writing code for) these two questions:

  1. How can we add (and organize) code so that when geth changes, it's easy for us to "bring in" those changes to the repo
    By easy, I mean most importantly that the process is not error-prone and ofc. that we don't lose too much time on margining/rebasing/whichever strategy we decide on
  2. How can we add (and organize) code so that when L2-rollup-geth wants to "bring in" our code changes, it's easy on them
    The definition of "easy" is the same as above

This PR tries to answer both requirements, but just for precompiles. That being said, even though we are "only" dealing with precompiles in this PR, the requirements for L1SLOAD required extending how precompiles work. Specifically, I had to:

  1. Find a way how to best "inject" eth.Client into the precompiled contract
  2. Find how to deal with the fact that not all L2s are accessing the required latest L1 block in the same way. E.g. for Arbitrum, block.number is the latest L1 block (not L2(!!!), and op-stack/scroll uses L2 contracts to store this info.

Implementation details

The idea was to create new "rollup" files so that we don't have too many changes (preferably just a couple of lines) in files that already exist in the official geth (e.g., vm/evm.go or vm/contracts.go) - this is why contracts_rollup.go exist.
And similarly, to create new files, which would L2-rollup-geth forks override - contracts_rollup_overrides.go. Ideally to change the functionality we are offering, the L2-rollup-geth would just replace or copy over the contracts_rollup_overrides.go file.

I need feedback on work so far that's why I'm opening this PR now. I don't think the specific implementation of L1SLOAD is that important ATM.

If you like the route I'm headed, I'd like to have a similar approach for other "stuff" we touch (e.g. flags.go). I don't think it'll be easy/possible to have this approach for everything, but if you agree, I'd like to experiment with it further.

Note

I tried to experiment with having a rollup/ folder (in root) where we could put all our changes, but that doesn't seem feasible:

CleanShot 2024-09-27 at 09 17 55@2x

As it is visible from the screenshot this would yield even huger diff; we would have to export private "stuff" from the folders/packages - this would be even messier

@mralj mralj changed the title Implements RIP-7728 [P1] Implements RIP-7728 Sep 26, 2024
@mralj mralj marked this pull request as ready for review September 26, 2024 18:32
@mralj mralj self-assigned this Sep 26, 2024
mralj pushed a commit that referenced this pull request Oct 1, 2024
@mralj mralj changed the base branch from core/eip/7708 to master October 4, 2024 09:00
@mralj mralj changed the title [P1] Implements RIP-7728 Implements RIP-7728 Oct 8, 2024
mralj and others added 4 commits October 9, 2024 10:10
I decided to implement it this way after trying to integrate code with Arbitrum and having a better understanding of the calls that are made to the NewEvm
This approach makes it easier to both override the default config, and to have the option to "not to think about it"
Making rollup-geth easier to sync with both upstream and L2s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant